from rest_framework import serializers
from .models import Coupon, UserCoupon


class CouponModelSerializer(serializers.ModelSerializer):
    """优惠卷的序列化器"""

    class Meta:
        model = Coupon
        fields = ["name", "sale", "coupon_type", "condition"]


class UserCouponModelSerializer(serializers.ModelSerializer):
    """我的优惠卷序列化器"""
    coupon = CouponModelSerializer()

    class Meta:
        model = UserCoupon
        fields = ["id", "start_time", "end_time", "coupon"]



